<template>
	<div class="productSee">
        <div class="productSeeall">
            <div class="img">
            	<img :src="shopform.image1" />
            </div>
            <div class="title">
            	{{shopform.title}}
            </div>
            <div class="content" v-html="shopform.description"></div>
            <!-- <div class="btm">
            	<el-button type="danger" size="small" @click="tiaozhuan">提交订单</el-button>
            </div> -->
        </div>
	</div>
</template>

<script>
	import axios from 'axios'
	export default {
		name: 'productSee',
		data () {
		  return {
			  shopform:{
			  	image1:"",
			  	title:"",
			  	description:"",
				id:""
			  },
              shop_id:""
		  }
		},
		created() {
            var that = this
			this.getshopdetail()
            console.log(this.$route.query.share_id)
            //根据连接如果有share_id直接按share_id,没有就获取店铺id，获取需要登录
            if(this.$route.query.share_id == "" || this.$route.query.share_id == undefined){
                axios.get('/api/gth/user/shop')
                    .then(response => {
                        if(response.data.msg.code == 0){
                            this.shop_id = response.data.data.shop_id
                        }else{
                            if(response.data.msg.code == 50401){that.$router.push({ path: "/login" }); return false}
                            that.$message.error(response.data.msg.info);
                        }
                    })
            }else{
                this.shop_id = this.$route.query.share_id
            }
            
		},
		methods:{
			tiaozhuan:function(){
				var user = JSON.parse(localStorage.getItem('USER'));
				if(this.$route.query.id == "" || this.$route.query.id == undefined){
					this.id = this.$route.query.order_page_id;
				}else{
					this.id = this.$route.query.id;
				}
				window.open(window.location.origin+"/webapp/merchant/templet1.html?id="+this.id+"&share_id="+this.shop_id)
			},
			//获取商品品详情
			getshopdetail:function(){
				var that = this;
				if(this.$route.query.id == "" || this.$route.query.id == undefined){
					this.id = this.$route.query.order_page_id;
				}else{
					this.id = this.$route.query.id;
				}
				axios.get('/api/plan-market/order-page?order_page_id='+this.id)
					.then(response => {
						if(response.data.msg.code == 0){
							
							that.shopform = response.data.data

						}else{
							that.$message.error(response.data.msg.info);
						}
					})
			},
		}
	}
	
</script>

<style lang="scss" scoped>
	@media screen and (min-width: 600px) {
	  .productSee{background: #efefef; padding: 20px 0; }
	}
	.productSee{background: #efefef;
        @media screen and (min-width: 600px) {
          .productSeeall{ width: 600px !important; margin: 0 auto; background: #FFFFFF; }
        }
        .productSeeall{ background: #FFFFFF; box-shadow: 0 0 10px #ccc;}
		.img{ 
            padding: 0.4rem;
			img{width: 100%; border-radius: 3px;}
		}
		.title{ font-size: 16px; padding: 15px; text-align: center;}
		.content{ line-height: 25px; padding: 0 15px;
			img{ max-width: 100%}
		}
		.btm{ text-align: center; background: #FFFFFF; width: 100%; padding: 10px 0; background: #efefef}
	}
</style>
